package com.zyc.app.woa.utils;

import com.umeng.analytics.MobclickAgent;
import com.zyc.app.woa.WoaApp;
import com.zyc.app.woa.data.AccountInfo;
import com.zyc.app.woa.data.ArticleItem;
import com.zyc.app.woa.db.AccountTable;
import com.zyc.app.woa.db.ArticlesTable;

import java.util.HashMap;

/**
 * Author: yingchang.zhang
 * Date  : 2014/8/29
 */
public class StatisticUtil {
    public static final String SEARCH_ACCOUNT = "search_account";
    public static final String ADD_ACCOUNT = "add_account";
    public static final String READ_ACCOUNT = "read_account";
    public static final String FAVORITE_ARTICLE = "favorite_article";
    public static final String READ_ORIGIN_ARTICLE = "read_origin_article";
    public static final String READ_ARTICLE = "read_article";

    public static void searchAccount(String keyWrods) {
        MobclickAgent.onEvent(WoaApp.getApp(), SEARCH_ACCOUNT, SEARCH_ACCOUNT);
    }

    public static void addAccount(AccountInfo accountInfo) {
        HashMap<String, String> map = new HashMap<String, String>();
        map.put(AccountTable.COLUMN_NAME, accountInfo.name);
        map.put(AccountTable.COLUMN_WX_ID, accountInfo.wxId);
        map.put(AccountTable.COLUMN_HREF, accountInfo.href);
        MobclickAgent.onEvent(WoaApp.getApp(), ADD_ACCOUNT, map);
    }

    public static void readAccount(AccountInfo accountInfo) {
        HashMap<String, String> map = new HashMap<String, String>();
        map.put(AccountTable.COLUMN_NAME, accountInfo.name);
        map.put(AccountTable.COLUMN_WX_ID, accountInfo.wxId);
        map.put(AccountTable.COLUMN_HREF, accountInfo.href);
        MobclickAgent.onEvent(WoaApp.getApp(), READ_ACCOUNT, map);
    }

    public static void favoriteArticle(ArticleItem articleItem) {
        HashMap<String, String> map = new HashMap<String, String>();
        map.put(ArticlesTable.COLUMN_TITLE, articleItem.title);
        map.put(ArticlesTable.COLUMN_MSG_URL, articleItem.url);
        MobclickAgent.onEvent(WoaApp.getApp(), FAVORITE_ARTICLE, map);
    }

    public static void readOriginArticle(ArticleItem articleItem) {
        HashMap<String, String> map = new HashMap<String, String>();
        map.put(AccountTable.NAME, articleItem.title);
        map.put(AccountTable.COLUMN_WX_ID, articleItem.url);
        MobclickAgent.onEvent(WoaApp.getApp(), READ_ORIGIN_ARTICLE, map);
    }

    public static void readArticle(ArticleItem articleItem) {
        HashMap<String, String> map = new HashMap<String, String>();
        map.put(AccountTable.NAME, articleItem.title);
        map.put(AccountTable.COLUMN_WX_ID, articleItem.url);
        MobclickAgent.onEvent(WoaApp.getApp(), READ_ARTICLE, map);
    }
}
